package com.zego.wawaji.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.zego.wawaji.base.module.ModuleMgr;
import com.noble.library.observer.MsgMgr;
import com.zego.wawaji.base.observer.MsgType;
import com.zego.wawaji.ui.UIShow;
import com.zego.wawaji.ui.base.BaseAppCompatActivity;
import com.zego.wawaji.wawaji_client.AppTinkerLike;

/**
 * 闪屏页
 * Created by Su on 2017/11/24.
 */
public class SplashActivity extends BaseAppCompatActivity {
    private final static long delayTime = 2000;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        isCanBack(false);
        super.onCreate(savedInstanceState);
        init();
    }

    private void init() {
        initData();
        int delay = (int) (delayTime - (System.currentTimeMillis() - AppTinkerLike.t));
        MsgMgr.getInstance().delay(() -> skipLogic(), delay);
    }

    private void initData() {
        ModuleMgr.getWawaMgr().reqSetting(null);
    }

    /**
     * Intent跳转
     */
    private void skipLogic() {
        if (ModuleMgr.getLoginMgr().checkAuthIsExist()) {
            MsgMgr.getInstance().sendMsg(MsgType.MT_App_Login, true);
            UIShow.showMainClearTask(this);
        } else {
            UIShow.showNavUserAct(this);
            finish();
        }
    }

    @Override
    public void onBackPressed() {
    }
}
